import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/app/modules/home/menu.model.dart';
import 'package:flutter_app/app/routes/app_pages.dart';
import 'package:get/get.dart';

class MenuView extends StatelessWidget {

  Menu menu;

  MenuView({Key? key, required this.menu}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Card(
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.only(bottom: 0, top: 8, left: 12),
              alignment: Alignment.centerLeft,
              child: Text(menu.functionName, style: const TextStyle(fontSize: 18)),
            ),
            GridView.count(
              crossAxisCount: 4, // 每行4個
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              padding: const EdgeInsets.all(8.0),
              mainAxisSpacing: 8.0,
              crossAxisSpacing: 8.0,
              children: menu.children.map((child) {
                return InkWell(
                  onTap: () {
                    Get.toNamed(Routes.RAW_INSTORE);
                  },
                  child: Column(
                    children: [
                      const IconButton(
                          icon: Icon(Icons.home, size: 30),
                          onPressed: null
                      ),
                      Text(
                          child.functionName,
                          style: const TextStyle(fontSize: 12),
                          overflow: TextOverflow.ellipsis,
                          maxLines: 1,
                      )
                    ],
                  ),
                );
              }).toList(),
            )
          ],
        )
    );
  }



}